import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ParentProductReturnRateConfigVO, ParentProductReturnRateConfigForm, ParentProductReturnRateConfigQuery } from '@/api/parentProduct/parentProductReturnRateConfig/types';

/**
 * 查询父产品退货率配置列表
 * @param query
 * @returns {*}
 */

export const listParentProductReturnRateConfig = (query?: ParentProductReturnRateConfigQuery): AxiosPromise<ParentProductReturnRateConfigVO[]> => {
  return request({
    url: '/parentProduct/parentProductReturnRateConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询父产品退货率配置详细
 * @param id
 */
export const getParentProductReturnRateConfig = (id: string | number): AxiosPromise<ParentProductReturnRateConfigVO> => {
  return request({
    url: '/parentProduct/parentProductReturnRateConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增父产品退货率配置
 * @param data
 */
export const addParentProductReturnRateConfig = (data: ParentProductReturnRateConfigForm) => {
  return request({
    url: '/parentProduct/parentProductReturnRateConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改父产品退货率配置
 * @param data
 */
export const updateParentProductReturnRateConfig = (data: ParentProductReturnRateConfigForm) => {
  return request({
    url: '/parentProduct/parentProductReturnRateConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除父产品退货率配置
 * @param id
 */
export const delParentProductReturnRateConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/parentProduct/parentProductReturnRateConfig/' + id,
    method: 'delete'
  });
};
